
{{ include("common/header.html")}}
<div class="admin">
    {{ include("common/settingNav.html")}}
    <link rel="stylesheet" href="{{_G['APP']}}/resource/wangEditor/css/wangEditor.min.css">
    <script type="text/javascript" src="{{_G['APP']}}/resource/js/jquery.min.js"></script>
    <script type="text/javascript" src="{{_G['APP']}}/resource/wangEditor/js/wangEditor.min.js"></script>
    <div class="aright"  style="margin-top: 0px;">

        <fieldset class="layui-elem-field layui-field-title" style="margin: 20px 30px 20px 20px;">
            <legend>密码修改</legend>
        </fieldset>

        <form class="layui-form bform" method="post">
            <input type="hidden" name="uid" value="{{userinfo['uid']}}">
            <div class="layui-form-item">
                <label class="layui-form-label">原始密码</label>
                <div class="layui-input-block">
                    <input type="password" name="old_password" required="" lay-verify="required" placeholder="必填内容" autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">输入密码</label>
                <div class="layui-input-block">
                    <input type="password" name="password" required="" lay-verify="required" placeholder="必填内容" autocomplete="off" class="layui-input">
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">重复密码</label>
                <div class="layui-input-block">
                    <input type="password" name="repass" required="" lay-verify="required" placeholder="必填内容" autocomplete="off" class="layui-input">
                </div>
            </div>

            <div class="layui-form-item">
                <div class="layui-input-block">
                    <button class="layui-btn" lay-submit="" lay-filter="formDemo">立即提交</button>
                    <button class="layui-btn layui-btn-primary" onclick="history.go(-1)">返回</button>
                </div>
            </div>
        </form>
    </div>
</div>
<script>
    //Demo
    layui.use(['layer', 'form'], function () {
        var form = layui.form;
        //监听提交
        form.on('submit(formDemo)', function (data) {
            var field = data.field;
            $.ajax({
                url: "{{G.url('admin/setting/password')}}",
                type: 'post',//请求的方式
                async: true,//是否异步  默认为异步
                data: field,//当前ajax请求的参数  
                dataType: "json",
                success: function (data) {//发送成功时的代码执行
                    if (data.code == 2001) {

                        if(data.data.repass)
                        {
                            layer.msg(data.data.repass,{icon:5});
                        }else if(data.data.old_password)
                        {
                            layer.msg(data.data.old_password,{icon:5});
                        }else if(data.data.password)
                        {
                            layer.msg(data.data.password,{icon:5});
                        }else{
                            layer.msg(data.data,{icon:5});
                        }

                        return false;
                    }

                    if (data.code == 1001) {
                        layer.msg(data.data);
                    }

                },
                error: function () {//失败时的代码执行
                    layer.msg("修改密码失败",{icon:5});
                    re_captcha();
                }

            });
            return false;
        });
    });
</script>
</body>
</html>